let layer = layui.layer
$(function () {
    let token = localStorage.getItem('token')
    if (!token) {
        location.href = './login.html'
    }
    $('#logout-btn').click(function (e) {
        e.preventDefault()

        layer.confirm('确认要退出吗?', {icon: 3, title:'提示'}, function(index){
            // 实现退出的功能：清除token,跳转到登录页面
            localStorage.removeItem('token')
            // 关闭弹窗
            layer.close(index)
            // 跳转到登录页面
            location.href = './login.html'
          });
    })
})